var twoSum = function (nums, target) {
    let map = new Map()
    for (let i = 0; i < nums.length; i++) {
        let num = nums[i]
        let rest = target - num
        if (map.get(rest) != undefined) {
            return [map.get(rest), i]
        }
        // 第一位存值，第二位存index
        map.set(num, i)
    }
};